package com.bltec.emergency.mapper;

import com.bltec.emergency.model.ResHelicopter;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface ResHelicopterMapper {
    //插入一条resHelicopter记录
    //model,company,production_time,base,manufacturer,registration_num
    @Insert("insert into res_helicopter (model,company,production_time,base,manufacturer,registration_num," +
            "create_by,create_time,enable) " +
            "values(#{model},#{company},#{productionTime},#{base},#{manufacturer},#{registrationNum},#{createBy},#{createTime},#{enable})")
    boolean insert(ResHelicopter resHelicopter);

    //通过id设置一条记录为不可用
    @Update("update res_helicopter set enable=0 where id=#{id}")
    boolean setDisableById(Long id);

    //通过id更新一条记录
    @Update("update res_helicopter set model=#{model},company=#{company},production_time=#{productionTime}," +
            "base=#{base},manufacturer=#{manufacturer},registration_num=#{registrationNum},update_by=#{updateBy},update_time=#{updateTime} where id=#{id}")
    boolean updateResHelicopterById(ResHelicopter resHelicopter);

    //查找符合id字段的记录
    @Select("select id,model,company,production_time,base,manufacturer,registration_num,create_by,create_time,update_by,update_time,enable" +
            " from res_helicopter where id =#{id} and enable=1")
    ResHelicopter getResHelicopterById(Long id);

    //查找所有记录
    @Select("select id,model,company,production_time,base,manufacturer,registration_num,create_by,create_time,update_by,update_time,enable" +
            " from res_helicopter where enable=1")
    List<ResHelicopter> selectAll();
}